package cn.wolfcode.education.web.controller;

import cn.wolfcode.education.domain.Work;
import cn.wolfcode.education.service.IWorkService;
import cn.wolfcode.education.util.JSONResult;
import cn.wolfcode.education.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("work")
public class WorkControler {

    @Autowired
    private IWorkService workService;
    //定位到页面
    @RequestMapping("work")
    public String work() {
        return "work";
    }

    //查询所有点任务
    @RequestMapping("list")
    @ResponseBody
    public PageResult queru() {
        //获取当前用户的主体
       /* Subject subject = SecurityUtils.getSubject();
        //判断当前用户是否拥有HR角色
        if (!subject.hasRole("HR")){
            //没有----是 普通员工,只等看到自己的信息
        }*/
        PageResult resule = (PageResult) workService.SelectAll();
        return resule;
    }

    /**
     * 创建一条新的任务
     */

    @RequestMapping("insert")
    @ResponseBody
    public JSONResult insert(Work newEven) {
        JSONResult jsonResult = new JSONResult();
        workService.insert(newEven);
        return jsonResult;
    }

}
